package com.xuelang.pipeline.entry.pipeline;

import com.xuelang.pipeline.app.pipeline.TagService;
import com.xuelang.pipeline.client.common.request.PageParam;
import com.xuelang.pipeline.client.common.result.ApiResult;
import com.xuelang.pipeline.client.common.result.PageRecord;
import com.xuelang.pipeline.client.pipeline.ITagService;
import com.xuelang.pipeline.client.pipeline.dto.PipelineTagQuery;
import com.xuelang.pipeline.client.pipeline.dto.TagDTO;
import com.xuelang.pipeline.client.pipeline.dto.TagQuery;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import jakarta.validation.Valid;
import java.util.List;

/**
 * 流水线标签服务web控制类
 *
 * @author xiwen.zxg
 * @since 2024/5/15
 */
@Slf4j
@RestController
@RequestMapping("/tag")
public class TagController implements ITagService {

    @Autowired
    private TagService tagService;

    @Override
    public ApiResult<PageRecord<TagDTO>> pageTagList(PageParam<TagQuery> dtoPageParam) {
        return ApiResult.success(tagService.pageList(dtoPageParam));
    }

    @Override
    public ApiResult<List<TagDTO>> conditionalTagList(TagQuery tagQuery) {
        return ApiResult.success(tagService.list(tagQuery));
    }

    @Override
    public ApiResult<Boolean> addTag(TagDTO tagDTO) {
        return ApiResult.success(tagService.add(tagDTO));
    }

    @Override
    public ApiResult<Boolean> updateTag(TagDTO tagDTO) {
        return ApiResult.success(tagService.update(tagDTO));
    }

    @Override
    public ApiResult<Boolean> batchSaveOrUpdate(List<TagDTO> tagDTOList) {
        return ApiResult.success(tagService.batchSaveOrUpdate(tagDTOList));
    }

    @Override
    public ApiResult<Boolean> deleteTag(String uuid) {
        return ApiResult.success(tagService.delete(uuid));
    }

    @Override
    public ApiResult<TagDTO> queryTag(String uuid) {
        return ApiResult.success(tagService.query(uuid));
    }

    @Override
    public Boolean modifyPipelineTags(@Valid PipelineTagQuery query) {
        return tagService.modifyPipelineTags(query);
    }
}